//从服务器主动发送请求调用接口, 编辑数据

const http = require('http')
const queryString = require("querystring")

options = {
    hostname: 'localhost',
    port: 3000,
    protocol: "http:",
    path: '/books/book',
    header: {
        'Content-Type': 'application/x-www/form-urlencoded'
    },
    method: 'put'   //默认get
}

let data = queryString.stringify(({
    id: "15",  //需要添加一个修改的id
    name: '萤窗小语',
    author: '刘墉',
    category: '文学',
    description: '一个个简单的小故事'
}))

req.write(data)

req.end()